package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.DealUserRelationQueryVo;
import cn.ywsj.ywsjmidtier.entity.VO.UserInfoVo;
import cn.ywsj.ywsjmidtier.service.WechatUserInfoFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @ClassName : WechatUserInfoController
 * @Author : Lenovo
 * @Date: 2021/7/17 16:03
 * @Description :
 */
@RestController
@Api(tags = "用户信息")
@RequestMapping("/wechat/member/account")
public class WechatUserInfoController {
    @Autowired
    private WechatUserInfoFeign wechatUserInfoFeign;

    /**
     * 用户信息
     * @return
     */
    @ApiOperation("用户信息")
    @PostMapping("/getuserinfo")
    public String getUserInfo(){
        return wechatUserInfoFeign.getUserInfo();
    }

    /**
     * 修改密码
     * @param userInfoVo
     * @param result
     * @param request
     * @param attr
     * @return
     */
    @ApiOperation("修改密码")
    @PostMapping("/ajaxmodifypasswd")
    public String modifyPassword(UserInfoVo userInfoVo, BindingResult result, HttpServletRequest request, RedirectAttributes attr){
        return wechatUserInfoFeign.modifyPassword(JsonObjectUtil.ObjectToJson(userInfoVo),result,request,attr);
    }

    /**
     * 忘记支付密码
     * @param userInfoVo
     * @param result
     * @return
     */
    @ApiOperation("忘记支付密码")
    @PostMapping("/ajaxmodifypaypasswdforget")
    public String modifyPayPasswordForget(UserInfoVo userInfoVo,BindingResult result){
        return wechatUserInfoFeign.modifyPayPasswordForget(JsonObjectUtil.ObjectToJson(userInfoVo),result);
    }

    /**
     * 我的供应商_供应商列表
     * @param dealUserRelationQueryVo
     * @param start
     * @param pageSize
     * @return
     */
    @ApiOperation("我的供应商_供应商列表")
    @PostMapping("/getsupcustnamelist")
    public String getSupCustNameList(DealUserRelationQueryVo dealUserRelationQueryVo, Integer start, Integer pageSize) {
        return wechatUserInfoFeign.getSupCustNameList(JsonObjectUtil.ObjectToJson(dealUserRelationQueryVo),start,pageSize);
    }

    @PostMapping(value = {"/ajaxmodifypaymentpasswd"})
    public String modifyPayPassword(UserInfoVo userInfoVo, BindingResult result) {
        return wechatUserInfoFeign.modifyPayPassword(JsonObjectUtil.ObjectToJson(userInfoVo),result);
    }

    @GetMapping(value = {"/spreadcenter"})
    public String spreadCenter() {
         return wechatUserInfoFeign.spreadCenter();
    }

    @RequestMapping({"/updateuserinfo"})
    public String updateUserInfo(UserInfoVo userInfoVo) {
         return wechatUserInfoFeign.updateUserInfo(JsonObjectUtil.ObjectToJson(userInfoVo));
    }

    @PostMapping(value = {"/ajaxmodifypaypasswdforapp"})
    public String modifyPayPasswordForApp(UserInfoVo userInfoVo, BindingResult result) {
        return wechatUserInfoFeign.modifyPayPasswordForApp(JsonObjectUtil.ObjectToJson(userInfoVo),result);
    }

    @RequestMapping({"/modifyuserinfo"})
    public String modifyUserInfo(UserInfoVo userInfoVo) {
        return wechatUserInfoFeign.modifyUserInfo(JsonObjectUtil.ObjectToJson(userInfoVo));
    }

    @RequestMapping({"/getusercode"})
    public String getQRImage(Long userId) {
       return  wechatUserInfoFeign.getQRImage(userId);
    }

    @PostMapping(value = {"/verificationtel"})
    public String verificationTel(String smsAuth, HttpSession session) {
        return wechatUserInfoFeign.verificationTel(smsAuth,session);
    }

    @PostMapping(value = {"/modifytel"})
    public String modifyTel(UserInfoVo userInfoVo, HttpSession session) {
         return wechatUserInfoFeign.modifyTel(JsonObjectUtil.ObjectToJson(userInfoVo),session);
    }
}
